#pragma once
#include "DXAMLCommon.h"

#include "Xcp_IDependencyObject.h"
#include "CXcpList.h"
#include "CModifiedValue.h"
#include "EnterParams.h"
#include "LeaveParams.h"


class CMetaData;
class CValue;
class CUIElement;
class CREATEPARAMETERS;

class CWeakRef;

class TextFormatting;
class TreeVisitor;
class InheritedProperties;
class CDependencyObject;


typedef void (__stdcall *PFNParentRenderChangedHandler)(CDependencyObject *,DirtyFlags::Value);



class CDependencyObject :
	public Xcp_IDependencyObject
{

	enum ValueOperationint
	{
		ValueOperationDefault,
		ValueOperationReevaluate,
		ValueOperationClearValue,
		ValueOperationFromSetValue,
	};

private: 
	void Initialize(CCoreServices * pCore);

protected: 
	CDependencyObject(CCoreServices * pCore);
	CDependencyObject();
	virtual                                  ~CDependencyObject();
	static  HRESULT                          ValidateAndInit(CDependencyObject * pDO, CDependencyObject * * ppDO);
	HRESULT                                  GetValue_ViaMethodCall(CDependencyProperty * pdp, CValue * pValue);
	HRESULT                                  SetValue_ViaMethodCall(CDependencyProperty * pdp, CValue * pValue);
	struct Xcp_IAutomationPeer *             OnCreateAutomationPeerInternal();
	virtual HRESULT                          PreTreeParentUpdated(CDependencyObject * pNewParent);
	virtual HRESULT                          PostTreeParentUpdated(CDependencyObject * pNewParent);
public: 
	HRESULT                                  UnpegManagedPeer(XBOOL isShutdownException);
	HRESULT                                  PegManagedPeer(XBOOL isShutdownException, XBOOL * pfPegged);
	static  HRESULT                          Create(CDependencyObject * * ppObject, CREATEPARAMETERS * pCreate);
	virtual XUINT32                          AddRef();
	virtual XUINT32                          Release();
	virtual XUINT32                          FinalizerRelease();
	virtual HRESULT                          OnManagedPeerCreated(XBOOL fIsCustomDOType, XBOOL fIsManagedPeerPegged);
	virtual void                             PreOnManagedPeerCreated();
	virtual void                             PostOnManagedPeerCreated();
	virtual HRESULT                          DisconnectManagedPeer();
	HRESULT                                  SetParticipatesInManagedTreeDefault();
	XBOOL                                    GetParticipatesInManagedTreeDefault();
	virtual HRESULT                          UpdateParentParticipatesInManagedTree();
	HRESULT                                  UpdateParentParticipatesInManagedTreeHelper(CDependencyObject * pParent);
protected: 							         
	XUINT32                                  ThreadSafeAddRef();
	XUINT32                                  ThreadSafeRelease();
	XUINT32                                  GetRefCount();
	XUINT32                                  TrackedAddRef();
	XUINT32                                  TrackedRelease();
private: 		                                     
	XUINT32                                  AddRefImpl(XUINT32 cRef);
	XUINT32                                  ReleaseImpl(XUINT32 cRef);
public: 							         
	virtual HRESULT                          GetValue(CDependencyProperty * pdp, CValue * pValue);
	HRESULT                                  GetValueByIndex(XUINT32 nPropertyIndex, CValue * pValue);
	HRESULT                                  GetValueInternal(enum ValueType type, CDependencyProperty * pdp, CValue * pValue);
	virtual HRESULT                          SetValue(CDependencyProperty * pdp, CValue * pValue);
	HRESULT                                  SetValueByIndex(XUINT32 nPropertyIndex, CValue * pValue);
	HRESULT                                  SetAnimatedValue(CDependencyProperty * pdp, CValue * pValue);
	HRESULT                                  ClearAnimatedValue(CDependencyProperty * pdp, CValue * pHoldEndValue);
	virtual HRESULT                          AddEventListener(CDependencyProperty * pdp, CValue * pValue, XINT32 iListenerType, CValue * pResult, XBOOL fHandledEventsToo);
	virtual HRESULT                          RemoveEventListener(CDependencyProperty * pdp, CValue * pValue);
	HRESULT                                  GetLocalValue(CDependencyProperty *, CValue *, XUINT32 *);
	HRESULT                                  ReadLocalValue(CDependencyProperty * pdp, CValue * pValue, XBOOL * pHasLocalValue, XBOOL * pIsTemplateBound);
	XBOOL                                    HasLocalOrModifierValue(CDependencyProperty * pdp);
	HRESULT                                  ClearValue(CDependencyProperty * pdp);
	HRESULT                                  InvalidateProperty(CDependencyProperty * pdp, enum BaseValueSource baseValueSource);
	HRESULT                                  SetPropertyIsDefault(CDependencyProperty * pdp);
	HRESULT                                  SetPropertyIsLocal(CDependencyProperty * pdp);
	HRESULT                                  RegisterDefaultValues();
	virtual struct Xcp_IDependencyObject *   GetParent();
	CXString *                               GetDebugLabel();
	virtual CXString *                       GetClassNameW();
	virtual XUINT32                          GetNamespaceIndex();
	virtual XUINT32                          OfTypeByIndex(XUINT32 nIndex);
	virtual CClassInfo *                     GetClassInfoW();
	HRESULT                                  GetCustomTypeFullName(CXString * * ppstrFullName);
	virtual CDependencyProperty *            GetContentProperty();
	CDependencyObject *                      GetDOPropertyValue(CMetaData * pPropertyInfo);
	virtual HRESULT                          GetParentOfFrameworkElement(CValue * pValue);
	virtual CDependencyProperty *            GetPropertyByName(XUINT32 cName, const XCHAR * pName, XBOOL bUpperCamelCase);
	virtual CDependencyProperty *            GetPropertyByIndex(XUINT32 nIndex);
	CDependencyProperty *                    GetPropertyByIndexInline(XUINT32 nIndex);
	virtual struct ICoreServices *           GetContextInterface();
	virtual struct Xcp_IAutomationPeer *     OnCreateAutomationPeer();
	virtual struct Xcp_IAutomationPeer *     GetAutomationPeer();
	virtual HRESULT                          SetAutomationPeer(struct Xcp_IAutomationPeer * pAP);
	virtual struct Xcp_IAutomationPeer *     OnCreateAutomationPeerImpl();
	virtual XUINT32                          GetAPChildren(struct Xcp_IAutomationPeer * * * pppReturnAP);
	virtual struct Xcp_IAutomationPeer *     GetPopupAssociatedAutomationPeer();
	CDependencyObject *                      GetTreeRoot(XBOOL fPublic);
	CDependencyObject *                      GetParentInternal(XBOOL fPublic);
	CUIElement *                             GetUIElementParentInternal(XBOOL fPublicOnly);
	virtual CDependencyObject *              GetInheritanceParentInternal(XBOOL fLogicalParent);
	virtual HRESULT                          OnInheritanceContextChanged();


	virtual HRESULT                          AddParent(CDependencyObject * pNewParent, XBOOL fPublic, PFNParentRenderChangedHandler pfnParentRenderChangedHandler);
	virtual HRESULT                          RemoveParent(CDependencyObject * pDO);
	virtual HRESULT                          HasParent(CDependencyObject * pCandidate, XBOOL * pfCandidateIsParent);
	virtual HRESULT                          SetParentForInheritanceContextOnly(CDependencyObject * pDO);
	virtual HRESULT                          UpdateState();
	XBOOL                                    ParticipatesInManagedTree();
	virtual XBOOL                            ParticipatesInManagedTreeInternal();
	virtual XBOOL                            ControlsManagedPeerLifetime();
	HRESULT                                  AddPeerReferenceToItem(CDependencyObject * pChild);
	HRESULT                                  RemovePeerReferenceToItem(CDependencyObject * pChild);
	HRESULT                                  SetPeerReferenceToProperty(CDependencyProperty * pdp, CDependencyObject * pValue, XBOOL fPreservePegNoRef);
	XBOOL                                    ShouldTrackWithPeerReferenceToProperty(CDependencyObject * pdo);
	XUINT32                                  UpdatePeerReferenceToProperty(CDependencyProperty * pdp, CDependencyObject * pdo, XBOOL fOldValueIsCached, XBOOL fNewValueNeedsCaching);
	virtual HRESULT                          HasProtectedContent(XBOOL * pfHasProtectedContent);
	virtual HRESULT                          SetCharacters(XUINT32 cString, XCHAR * pString);
	virtual HRESULT                          InitInstance();
	virtual HRESULT                          CreationComplete();
	HRESULT                                  ClearPropertySetFlag(CDependencyProperty *);
	XBOOL                                    IsPropertyDefault(CDependencyProperty * pdp);
	XBOOL                                    IsPropertySetBySlot(XUINT32 slot);
	XBOOL                                    IsPropertyDefaultByIndex(XUINT32 nIndex);
	HRESULT                                  GetAnimationBaseValue(CDependencyProperty * pDP, CValue * pValue);
	virtual HRESULT                          GetMentor(CDependencyObject * * ppMentor);
	XUINT32                                  UseLogicalParent(XUINT32 userIndex);
	XBOOL                                    IsValueInherited(CDependencyProperty *);
	HRESULT                                  GetValueInherited(CDependencyProperty * pdp, CValue * pValue);
	virtual XBOOL                            HasInheritedProperties();
	virtual HRESULT                          PullInheritedTextFormatting();
	virtual TextFormatting * *               GetTextFormattingMember();
	static  HRESULT                          EnsureTextFormatting(CDependencyObject * pObject, CDependencyProperty * pProperty, XBOOL forGetValue);
	HRESULT                                  UpdateTextFormatting(CDependencyProperty * pProperty, XBOOL forGetValue, TextFormatting * * ppTextFormatting);
	HRESULT                                  EnsureTextFormattingForRead();
	HRESULT                                  GetTextFormatting(const TextFormatting * * ppTextFormatting);
	HRESULT                                  UpdateInheritedPropertiesForRead();
	HRESULT                                  EnsureInheritedPropertiesForRead();
	void                                     DisconnectInheritedProperties();
	HRESULT                                  GetInheritedProperties(const InheritedProperties * * ppInheritedProperties);
	static  HRESULT                          EnsureInheritedProperties(CDependencyObject * pObject, CDependencyProperty * pProperty, XBOOL forGetValue);
	HRESULT                                  GetParentTextFormatting(TextFormatting * * ppTextFormatting);
	virtual XBOOL                            IsRightToLeft();
	virtual XINT32                           IsPropertySetByStyle(CDependencyProperty * pdp);
	virtual HRESULT                          SetIsSetByStyle(CDependencyProperty * pdp, XBOOL fSet);
	virtual XINT32                           DoesStyleHaveBinding(CDependencyProperty * pdp);
	virtual HRESULT                          SetStyleHasBinding(CDependencyProperty * pdp, XBOOL fSet);
	virtual XBOOL                            GetCoercedIsEnabled();
	virtual XBOOL                            SkipNameRegistrationForChildren();
	virtual XBOOL                            GetUseLayoutRounding();
	CCoreServices *                          GetContext();
	void                                     ContextAddRef();
	void                                     ContextRelease();
	static  void                             NWSetRenderDirty(CDependencyObject * pTarget, enum DirtyFlags::Value flags);
protected: 
	virtual void                             NWPropagateDirtyFlag(enum DirtyFlags::Value flags);
	PFNParentRenderChangedHandler            NWGetRenderChangedHandlerInternal();
	void                                     NWPropagateInheritedDirtyFlag(CUIElement * pParent, enum DirtyFlags::Value flags);
public: 
	XBOOL                                    GetWantsInheritanceContextChanged();
	void                                     SetParserParentLock();
	void                                     ResetParserParentLock();
	void *                                   GetPropertyOffset(CDependencyProperty * pdp, XBOOL forGetValue);
	HRESULT                                  SetValueByKnownId(XUINT32 uKnownID, XUINT32 pValue);
	HRESULT                                  SetValueByKnownId(XUINT32 uKnownID, XFLOAT pValue);
	HRESULT                                  SetValueByKnownId(XUINT32 uKnownID, XINT32 pValue);
	HRESULT                                  SetValueByKnownId(XUINT32 uKnownID, CDependencyObject * pValue);
	HRESULT                                  SetValueByKnownId(XUINT32 uKnownID, CValue & pValue);
	HRESULT                                  GetDefaultValue(CDependencyProperty * pdp, CValue * pDefaultValue);
	virtual HRESULT                          NotifyPropertyChanged(CDependencyProperty * pdp, CValue * pValue);
private: 
	HRESULT                                  SetParent(CDependencyObject * pNewParent, XBOOL fPublic, PFNParentRenderChangedHandler   pfnNewParentRenderChangedHandler);
	CDependencyObject *                      MapPropertyAndGroupOffsetToDO(const struct RenderProperty * pProperty);
	HRESULT                                  ResetReferencesFromChildren();
	HRESULT                                  RegisterDefaultValueForProperty(CDependencyProperty * pdp);
	HRESULT                                  RegisterDefaultValuesForTypeOf(CDependencyObject * pObject);
	HRESULT                                  ValidateCValue(CDependencyProperty * pdp, CClassInfo * pClass, CValue * pValue, enum ValueType valueType);
	HRESULT                                  ValidateFloatValue(XUINT32 nPropertyIndex, XFLOAT eValue);
	HRESULT                                  ValidateSignedValue(XUINT32 nPropertyIndex, XINT32 nValue);
	HRESULT                                  ValidateThicknessValue(XUINT32 nPropertyIndex, XFLOAT * peValue, XUINT16 nCount);
	HRESULT                                  ValidateCornerRadiusValue(XUINT32 nPropertyIndex, XFLOAT * peValue, XUINT16 nCount);
	HRESULT                                  ValidateGridLengthValue(XUINT32 nPropertyIndex, struct XGRIDLENGTH * pGridLength);
	HRESULT                                  TryProcessingStyleWithBinding(CDependencyProperty * pdp, CValue * pEffectiveValue, enum BaseValueSource baseValueSource, XBOOL * pbProcessed);
protected: 
	HRESULT                                  ResetReferenceFromChild(CDependencyObject * pChild);
	HRESULT                                  UpdateParentInPeerTree(CDependencyObject * pOldParent, CDependencyObject * pParent);
	void                                     SetIsValueOfInheritedProperty(XBOOL fValueOfInheritedProperty);
	XBOOL                                    IsValueOfInheritedProperty();
	HRESULT                                  UpdateEffectiveValue(CDependencyProperty * pdp, CValue * pValue, CModifiedValue * pModifiedValue, XUINT32 valueOperation);
	HRESULT                                  EvaluateEffectiveValue(CDependencyProperty * pdp, CModifiedValue * pModifiedValue, XUINT32 valueOperation, CValue * pEffectiveValue, enum BaseValueSource * pBaseValueSource, XBOOL * pbValueSetNeeded);
	HRESULT                                  EvaluateBaseValue(CDependencyProperty * pdp, CModifiedValue * pModifiedValue, XUINT32 valueOperation, CValue * pBaseValue, enum BaseValueSource * pBaseValueSource, XBOOL * pbValueSetNeeded);
	HRESULT                                  SetBaseValueSource(CDependencyProperty * pdp, enum BaseValueSource baseValueSource);
	HRESULT                                  GetBaseValueSource(CDependencyProperty * pdp, enum BaseValueSource * pBaseValueSource);
	HRESULT                                  EnsureModifiedValues();
	HRESULT                                  CreateModifiedValue(CDependencyProperty * pdp, CModifiedValue * * ppModifiedValue);
	HRESULT                                  DeleteModifiedValue(CModifiedValue * pModifiedValue);
	HRESULT                                  GetModifiedValue(CDependencyProperty * pdp, CModifiedValue * * ppModifiedValue);
	HRESULT                                  GetEffectiveValue(CDependencyProperty *, CValue *, CModifiedValue *, CValue *);
	virtual HRESULT                          GetValueFromStyle(XUINT32 uPropertyId, XBOOL bIsCoreProperty, CValue * pValue, XBOOL * pbGotValue);
	virtual HRESULT                          GetValueFromBuiltInStyle(XUINT32 uPropertyId, XBOOL bIsCoreProperty, CValue * pValue, XBOOL * pbGotValue);
	virtual HRESULT                          MarkInheritedPropertyDirty(CDependencyProperty * pdp, CValue * pValue);
private: 
	HRESULT                                  SetName(const CXString * pstrName);
	CDependencyObject *                      GetNamescopeOwnerInternal(CDependencyObject * pFirstOwner);
public: 
	HRESULT                                  ClearNameInternal();
	virtual HRESULT                          RegisterName(CDependencyObject * pNamescopeOwner, XBOOL bTemplateNamescope);
	HRESULT                                  UnregisterName(CDependencyObject * pNamescopeOwner);
protected: 
	virtual XBOOL                            CanEnterImpl(CDependencyObject * pNamescopeOwner);
	virtual HRESULT                          EnterImpl(CDependencyObject * pNamescopeOwner, struct EnterParams params);
	virtual HRESULT                          LeaveImpl(CDependencyObject * pNamescopeOwner, struct LeaveParams params);
	virtual HRESULT                          InvokeImpl(CDependencyProperty * pdp, CDependencyObject * pNamescopeOwner);
	virtual HRESULT                          RevokeImpl(CDependencyProperty * pdp, CDependencyObject * pNamescopeOwner);
	void                                     SetParentInternal(CDependencyObject * pNewParent, XBOOL fFireChanged, PFNParentRenderChangedHandler   pfnNewParentRenderChangedHandler);
	virtual void                             NotifyParentChange(CDependencyObject * pNewParent, PFNParentRenderChangedHandler   pfnNewParentRenderChangedHandler);
	HRESULT                                  SetEffectiveValue(CDependencyProperty * pdp, CValue * pValue);
	virtual HRESULT                          PerformEmergencyInvalidation(CDependencyObject * pToBeReparented);
public: 
	virtual XBOOL                            IsActive();
	XBOOL                                    IsDestructing();
	virtual XBOOL                            IsFiringEvents();
	virtual XBOOL                            CanEnter(CDependencyObject * pNamescopeOwner);
	virtual HRESULT                          Enter(CDependencyObject * pNamescopeOwner, struct EnterParams params);
	virtual HRESULT                          Leave(CDependencyObject * pNamescopeOwner, struct LeaveParams params);
	HRESULT                                  Invoke(CDependencyProperty * pdp, CDependencyObject * pNamescopeOwner, XBOOL bLive);
	HRESULT                                  Revoke(CDependencyProperty * pdp, CDependencyObject * pNamescopeOwner, XBOOL bLive);
	CDependencyObject *                      GetNamescopeOwner();
	virtual CDependencyObject *              GetNamescopeParent();
	HRESULT                                  SetError(enum ErrorType eType, XUINT32 iErrorCode, XUINT32 cParams, struct XSTRING * * ppParam);
	virtual HRESULT                          SetTemplatedParent(CDependencyObject * pDO);
	virtual HRESULT                          SetTemplateBinding(struct XamlPropertyToken tokTargetProperty, struct XamlPropertyToken tokSourceProperty);
	virtual HRESULT                          SubscribeToPropertyChanges(struct XamlPropertyToken tokSourceProperty, CDependencyObject * pdoTarget, struct XamlPropertyToken tokTargetProperty);
	virtual HRESULT                          RemoveTemplateBinding(CDependencyObject * pdoTarget, CDependencyProperty * pdpTarget);
	virtual XBOOL                            IsUpdatingBindings();
	virtual CDependencyObject *              GetTemplatedParent();
	virtual struct IPALUri *                 GetBaseUri();
	virtual void                             SetBaseUri(struct IPALUri * pUri);
	virtual XBOOL                            CanChangeBaseUri();
protected: 
	HRESULT                                  ClonePropertySetField(const CDependencyObject * pdoOriginal);
public: 
	virtual void                             PropagateLayoutDirty(XBOOL affectsMeasure, XBOOL affectsArrange);
	HRESULT                                  CreateManagedPeer(XBOOL fPegNoRef, XBOOL fPegRef, XBOOL isShutdownException, XBOOL * pfPegged);
	void                                     SetHasManagedPeer(XBOOL fHasManagedPeer, XBOOL fIsCustomType);
	int                                      HasManagedPeer();
	HRESULT                                  PegManagedPeerNoRef();
	HRESULT                                  UnpegManagedPeerNoRef();
	XBOOL                                    IsCustomType();
	virtual XUINT32                          GetTypeIndex() const;
	virtual void                             SetAssociated(XBOOL fIsAssociated);
	XBOOL                                    IsAssociated();
	XBOOL                                    ParserOwnsParent();
	virtual XBOOL                            DoesAllowMultipleAssociation();
	virtual XBOOL                            DoesAllowMultipleParents();
	XBOOL                                    IsParentAware();
	void                                     SetIsNamescopeMember(XBOOL fIsNamescopeMember);
	XBOOL                                    IsNamescopeMember();
	void                                     SetIsNamescopeOwner(XBOOL fIsNamescopeOwner);
	XBOOL                                    IsNamescopeOwner();
	void                                     SetIsPermanentNamescopeOwner(XBOOL fIsPermanentNamescopeOwner);
	XBOOL                                    IsPermanentNamescopeOwner();
	void                                     SetShouldRegisterInParentNamescope(XBOOL fShouldRegisterInParentNamescope);
	XBOOL                                    ShouldRegisterInParentNamescope();
	void                                     SetHasUsageName(XBOOL fHasUsageName);
	XBOOL                                    HasUsageName();
	void                                     SimulateFreeze();
	void                                     SetIsParsing(XBOOL fIsParsing);
	XBOOL                                    IsParsing();
	void                                     SetHasWeakRef(XBOOL fHasWeakRef);
	XBOOL                                    HasWeakRef();
	void                                     SetIsTemplateNamescopeMember(XBOOL fIsTemplateNamescopeMember);
	XBOOL                                    IsTemplateNamescopeMember();
	void                                     SetIsManagedPeerPeggedNoRef(XBOOL fIsPegged);
	XBOOL                                    IsManagedPeerPeggedNoRef();
	void                                     SetWantsInheritanceContextChanged(XBOOL fWantsInheritanceContextChanged);
	XBOOL                                    HasDragEnter();
	void                                     SetDragEnter(XBOOL bVal);
	XBOOL                                    IsDragInputNodeDirty();
	void                                     SetDragInputNodeDirty(XBOOL bVal);
	XBOOL                                    IsProcessingEnterLeave();
private: 		                             
	void                                     SetIsProcessingEnterLeave(XBOOL fIsProcessingEnterLeave);
	XBOOL                                    IsParentValid();
	virtual XBOOL                            IsDependencyObject();
protected: 		                             
	virtual XBOOL                            CanCreateInPeerUpdate();
private: 		                             
	static XBOOL                             CanCreateParentInPeerUpdate(CDependencyObject * pParent);
public: 
	static HRESULT                           VisualTreeWalk(struct Xcp_IDependencyObject * pObject, XUINT32 cArgs, CValue * ppArgs, CValue * pResult);
	void                                     Visit(TreeVisitor * pVisitor);
	virtual void                             VisitChildren(TreeVisitor * pVisitor);
	virtual void                             VisitImpl(TreeVisitor * pVisitor);


	static const struct XPOINTF                     DefaultValuePoint;
	static const struct XRECTF_WH                   DefaultValueRect;
	static const struct XGRIDLENGTH                 DefaultValueGridLength;
	static const struct XPOINTD                     DefaultValueDPoint;
	static const double                             DefaultValueDouble;

	typedef union BitField
	{
		XUINT32 * pointer;
		XUINT32 bits;

	} _BitField;



public: 
	HRESULT                                  SetPropertyBitField(CDependencyObject::BitField & field, XUINT16 cProperties, XUINT32 nBit);
	void                                     ClearPropertyBitField(union CDependencyObject::BitField & field, XUINT16 cProperties, XUINT32 nBit);
	XBOOL                                    GetPropertyBitField(union CDependencyObject::BitField & field, XUINT16 cProperties, XUINT32 nBit);
	XBOOL                                    IsBitFieldValidPointer();
	virtual HRESULT                          GetParentCount(XUINT32 * puiCount);
	virtual HRESULT                          GetParentItem(CDependencyObject * * ppDO, XUINT32 uiIndex);


public:
	CXString *                               m_pstrName;
	InheritedProperties *                    m_pInheritedProperties;
protected: 
	CCoreServices *                          m_pCore;
	void *                                   m_pCorePartTimeStrongPointerContext;
	struct IPALUri *                         m_pPreferredBaseURI;
private: 
	CDependencyObject *                      m_pParent;
	CWeakRef *                               m_pMentor;
	XUINT32                                    m_cRef;

	struct DependencyObjectBitFields
	{
		XUINT32 fLive                                   :1; //0000 low
		XUINT32 fIsAssociated                           :1; //0001
		XUINT32 fIsNamescopeOwner                       :1; //0002
		XUINT32 fIsNamescopeMember                      :1; //0003
		XUINT32 fIsPermanentNamescopeOwner              :1; //0004
		XUINT32 fShouldRegisterInParentNamescope        :1; //0005
		XUINT32 fIsTemplateNamescopeMember              :1; //0006
		XUINT32 fParentIsPublic                         :1; //0007
		XUINT32 fNeedToReleaseCore                      :1; //0008
		XUINT32 fIsValidAPointer                        :1; //0009
		XUINT32 fHasManagedPeer                         :1; //0010
		XUINT32 fIsManagedPeerPeggedNoRef               :1; //0011
		XUINT32 fParserOwnsParent                       :1; //0012
		XUINT32 fSimulatingFrozen                       :1; //0013
		XUINT32 fIsCustomType                           :1; //0014
		XUINT32 fIsParsing                              :1; //0015
		XUINT32 fHasWeakRef                             :1; //0016
		XUINT32 fIsProcessingEnterLeave                 :1; //0017
		XUINT32 fIsProcessingAsyncSetValue              :1; //0018
		XUINT32 fParticipatesInManagedTreeDefault       :1; //0019
		XUINT32 fValueOfInheritedProperty               :1; //0020
		XUINT32 fWantsInheritanceContextChanged         :1; //0021
		XUINT32 fParentIsInheritanceContextOnly         :1; //0022
		XUINT32 fHasUsageName                           :1; //0023
		XUINT32 isParentAnActiveRootVisual              :1; //0024
		XUINT32 hasInputDragEnter                       :1; //0025
		XUINT32 isDragInputNodeDirty                    :1; //0026 high
		//0027
		//0028
		//0029
		//0030
		//0031


	};

	struct DependencyObjectBitFields         m_bitFields;
	union BitField                           m_valid;

private: 
	CXcpList<CModifiedValue> *               m_pModifiedValues;
	PFNParentRenderChangedHandler            m_pfnNWRenderChangedHandler;
	struct  
	{
		XUINT32                                  m_hasEverHadManagedPeer:1;
		XUINT32                                  m_fCalledOnManagedPeerCreated:1;
	};

};



